import type { App } from 'vue'
import { deepClone } from '@/utils/index'
import emptyImg from '@/assets/empty/common.png'
function getImg(url: string, type = 1) {
  if (!url) return emptyImg
  if (url.includes('xiaobaiquan')) {
    if (type === 2) {
      return `${url}?x-oss-process=image/resize,w_180,m_lfit/format,webp/quality,q_80`
    }
    return `${url}?x-oss-process=image/resize,p_12`
  } else if (url.includes('picgo')) {
    const arr = url.split('.')
    // md th
    arr.splice(arr.length - 1, 0, 'md')
    return arr.join('.')
  }
  return url
}
export function install(app: App) {
  /* 深克隆 */
  app.provide('$clone', deepClone)
  app.config.globalProperties.$getImg = getImg
}
